package com.joyance.test_servlet.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestHttpServletRequest extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.println("HttpServletRequest================");
		//getAuthType
		System.out.println("HttpServletRequest.getAuthType()="+req.getAuthType());
		//getCookies;
		System.out.println("req.getCookies() begin=============");
		Cookie[] cookies=req.getCookies();
		for(Cookie cookie:cookies){
			System.out.println(cookie.getName()+"="+cookie.getValue());
		}
		System.out.println("req.getCookies() end=============");
		//getDateHeader
        long ifModifiedSince=req.getDateHeader("If-Modified-Since");
        System.out.println("req.getDateHeader(\"If-Modified-Since\")="+ifModifiedSince);
        //getHeader
        System.out.println("req.getHeader(\"user-agent\")="+req.getHeader("user-agent"));
        System.out.println("req.getHeader(\"sex\")="+req.getHeader("sex"));
        //getMethod
        System.out.println("req.getMethod()="+req.getMethod());
        //getPathInfo
        System.out.println("req.getPathInfo()="+req.getPathInfo());
        //getPathTranslated
        System.out.println("req.getPathTranslated()="+req.getPathTranslated());
        //getQueryString
        System.out.println("req.getQueryString()="+req.getQueryString());
        //getRemoteUser
        System.out.println("req.getRemoteUser()="+req.getRemoteUser());
        //getRequestedSessionId
        System.out.println("req.getRequestedSessionId()="+req.getRequestedSessionId());
        //getSession()
        System.out.println("req.getSession().getAttribute(\"animal\")="+req.getSession().getAttribute("animal"));
        //getRequestURI()
        System.out.println("req.getRequestURI()="+req.getRequestURI());
        //getServletPath
        System.out.println("req.getServletPath()="+req.getServletPath());
        //isRequestedSessionIdValid
        System.out.println("req.isRequestedSessionIdValid()="+req.isRequestedSessionIdValid());
        //isRequestedSessionIdFromCookie
        System.out.println("req.isRequestedSessionIdFromCookie()="+req.isRequestedSessionIdFromCookie());
        //isRequestedSessionIdFromURL
        System.out.println("req.isRequestedSessionIdFromURL()="+req.isRequestedSessionIdFromURL());
        //isRequestedSessionIdFromUrl
        System.out.println("req.isRequestedSessionIdFromUrl()="+req.isRequestedSessionIdFromUrl());
	}
	

}
